﻿
Imports OpenTK.Graphics.OpenGL
Public Class Vehicle
    Private localmR As OGL
    Private mVertexBuffer() As Double = {}
    Private mVertexBufferLineLeft() As Double = {}
    Private mVertexBufferLineRight() As Double = {}

    Public Sub New(ByVal paramWorldRenderer As OGL)
        Dim arrayOfFloat1(8) As Double
        arrayOfFloat1(0) = (-3.0F / 2.0F)
        arrayOfFloat1(1) = 0.0F
        arrayOfFloat1(2) = 0.0F
        arrayOfFloat1(3) = (3.0F / 2.0F)
        arrayOfFloat1(4) = 0.0F
        arrayOfFloat1(5) = 0.0F
        arrayOfFloat1(6) = 0.0F
        arrayOfFloat1(7) = (2.0F * 3.0F)
        arrayOfFloat1(8) = 0.0F

        localmR = paramWorldRenderer
        Dim f As Single = paramWorldRenderer.workwith / 2.0F
        Dim arrayOfFloat2() As Double = {f, 0.0F, 0.1F, f, 500.0F, 0.1F}
        Dim arrayOfFloat3(5) As Double
        arrayOfFloat3(0) = (-f)
        arrayOfFloat3(1) = 0.0F
        arrayOfFloat3(2) = 0.1F
        arrayOfFloat3(3) = (-f)
        arrayOfFloat3(4) = 500.0F
        arrayOfFloat3(5) = 0.1F


        mVertexBuffer = arrayOfFloat1

        mVertexBufferLineRight = arrayOfFloat2

        mVertexBufferLineLeft = arrayOfFloat3


    End Sub

    Public Overridable Sub draw()
        Dim f As Single = localmR.workwith / 2.0F
        Dim arrayOfFloat1() As Double = {f, 0.0F, 0.1F, f, 500.0F, 0.1F}
        Dim arrayOfFloat2(5) As Double
        arrayOfFloat2(0) = (-f)
        arrayOfFloat2(1) = 0.0F
        arrayOfFloat2(2) = 0.1F
        arrayOfFloat2(3) = (-f)
        arrayOfFloat2(4) = 500.0F
        arrayOfFloat2(5) = 0.1F
        mVertexBufferLineRight = arrayOfFloat1
        mVertexBufferLineLeft = arrayOfFloat2

        GL.Enable(EnableCap.CullFace)
        GL.Enable(EnableCap.DepthTest)


        GL.PopMatrix()
        GL.Begin(BeginMode.Triangles)
        GL.Color4(0.0F, 1.0F, 0.0F, 0.8F)
        GL.Vertex3(0.0F, (2.0F * 3.0F), 0.0F)
        GL.Vertex3((-3.0F / 2.0F), 0.0F, 0.1F)
        GL.Vertex3((3.0F / 2.0F), 0.0F, 0.1F)
        GL.End()

        GL.EnableVertexAttribArray(EnableCap.VertexArray)
        GL.Color4(0.0F, 1.0F, 0.0F, 0.8F)
        GL.VertexPointer(3, VertexPointerType.Float, 0, mVertexBuffer)
        GL.DrawArrays(BeginMode.TriangleStrip, 0, 2)
        GL.DisableVertexAttribArray(EnableCap.VertexArray)

        GL.LineWidth(4.0F)
        GL.EnableVertexAttribArray(EnableCap.VertexArray)
        GL.VertexPointer(3, VertexPointerType.Float, 0, mVertexBufferLineRight)
        GL.DrawArrays(BeginMode.Lines, 0, 1)
        GL.DisableVertexAttribArray(EnableCap.VertexArray)

        GL.EnableVertexAttribArray(EnableCap.VertexArray)
        GL.VertexPointer(3, VertexPointerType.Float, 0, mVertexBufferLineLeft)
        GL.DrawArrays(BeginMode.Lines, 0, 1)
        GL.DisableVertexAttribArray(EnableCap.VertexArray)
        GL.LineWidth(1.0F)



    End Sub

End Class
